added Feb 2001 SDK
[windows-sources.git] / shared source / sscli20 / jscript / engine / vsaitem.cs
blobab35e6dde2ced7821ace8ef6a52dd170ddb37815
1 // ==++==
2 //
3 //
4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
5 //
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
10 //
11 // You must not remove this notice, or any other, from this software.
12 //
13 //
14 // ==--==
16 namespace Microsoft.JScript{
18 using Microsoft.JScript.Vsa;
19 using System;
20 using System.Collections;
21 using System.Globalization;
22 using Microsoft.Vsa;
23 using System.Security.Permissions;
25 public abstract class VsaItem : IVsaItem{
26 protected string name;
27 internal string codebase;
28 internal VsaEngine engine;
29 protected VsaItemType type;
30 protected VsaItemFlag flag;
31 protected bool isDirty;
33 internal VsaItem(VsaEngine engine, string itemName, VsaItemType type, VsaItemFlag flag){
34 this.engine = engine;
35 this.type = type;
36 this.name = itemName;
37 this.flag = flag;
38 this.codebase = null;
39 this.isDirty = true;
42 internal virtual void CheckForErrors(){
45 internal virtual void Close(){
46 this.engine = null;
49 internal virtual void Compile(){}
52 internal virtual Type GetCompiledType(){
53 // only code items have a compiled type
54 return null;
57 public virtual bool IsDirty{
58 [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
59 get{
60 if (this.engine == null)
61 throw new VsaException(VsaError.EngineClosed);
62 return this.isDirty;
64 [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
65 set{
66 if (this.engine == null)
67 throw new VsaException(VsaError.EngineClosed);
68 this.isDirty = value;
72 [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
73 public virtual Object GetOption(String name){
74 if (this.engine == null)
75 throw new VsaException(VsaError.EngineClosed);
76 if (0 == String.Compare(name, "codebase", StringComparison.OrdinalIgnoreCase))
77 return this.codebase;
78 throw new VsaException(VsaError.OptionNotSupported);
81 public virtual String Name{
82 [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
83 get{
84 if (this.engine == null)
85 throw new VsaException(VsaError.EngineClosed);
86 return this.name;
88 [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
89 set{
90 if (this.engine == null)
91 throw new VsaException(VsaError.EngineClosed);
92 if (this.name == value)
93 return;
94 if (!this.engine.IsValidIdentifier(value))
95 throw new VsaException(VsaError.ItemNameInvalid);
96 foreach (IVsaItem item in this.engine.Items){
97 if (item.Name.Equals(value))
98 throw new VsaException(VsaError.ItemNameInUse);
100 this.name = value;
101 this.isDirty = true;
102 this.engine.IsDirty = true;
106 internal virtual void Remove(){
107 this.engine = null;
110 internal virtual void Reset(){}
112 internal virtual void Run(){}
114 [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
115 public virtual void SetOption(String name, Object value){
116 if (this.engine == null)
117 throw new VsaException(VsaError.EngineClosed);
118 if (0 == String.Compare(name, "codebase", StringComparison.OrdinalIgnoreCase))
119 this.codebase = (string)value;
120 else
121 throw new VsaException(VsaError.OptionNotSupported);
122 this.isDirty = true;
123 this.engine.IsDirty = true;
126 public VsaItemType ItemType{
127 [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
128 get{
129 if (this.engine == null)
130 throw new VsaException(VsaError.EngineClosed);
131 return this.type;